home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / zapem-0.000 / zapem-0 / zapem / soundIt.h < prev    next >
C/C++ Source or Header  |  1995-05-06  |  3KB  |  87 lines

  1. /* SoundIt library 0.04
  2.  
  3.    Copyright 1994 Brad Pitzel  pitzel@cs.sfu.ca
  4.  
  5.    Feel free to use/distribute/modify as long as proper credits
  6.    are included.
  7. */
  8.  
  9. /* Designed for digital sound effects in interactive apps (games, drum
  10.    machines, digital organs, ???)
  11.  
  12.    Will mix channels of mono 8-bit raw samples, & play back in "real-time".
  13.    Each channel can only play one sample at a time, but all
  14.    channels can play a different sample simultaneously.                 
  15.    
  16.    If you have sox, use the ' -t .ub ' option to make samples
  17.    that this library will play properly.
  18.  
  19. */
  20.  
  21. #ifndef SOUNDIT_VERS
  22. #define SOUNDIT_VERS "0.04"
  23.  
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26.  
  27. /* 00002 = 2 fragments   */
  28. /* 00007 = means each fragment is 2^7 or 128 bytes */
  29. /* See voxware docs (in /usr/src/linux/drivers/sound) for more info */
  30. #define FRAG_SPEC 0x00020007
  31.  
  32. /*==========================================================================*/
  33. struct Sample
  34.     {
  35.     unsigned char *data;    /* unsigned 8-bit raw samples */
  36.     int len;            /* length of sample in bytes  */
  37.     };
  38.  
  39. typedef struct Sample Sample;
  40.  
  41. /*==========================================================================*/
  42. /* given the name of a .raw sound file, load it into the Sample struct */ 
  43. /* pointed to by 'sample'                                              */
  44. int 
  45. Snd_loadRawSample( const char *file, Sample *sample );
  46.  
  47. /* also load .au files */
  48. int 
  49. Snd_loadUlawSample( const char *file, Sample *sample );
  50.  
  51.  
  52. /*==========================================================================*/
  53. /* init sound device, etc..                                                 */
  54. /* num_snd  = the number of samples in the sample array *sa                 */
  55. /* sa       = the sample array                            */
  56. /* freq     = the rate (Hz) to play back the samples                        */
  57. /* channels = # of channels to mix                                          */
  58. /* sound_device = a char string for the sound device, eg, "/dev/dsp"        */
  59. /* returns: 0=success, -1=failure.*/
  60. int 
  61. Snd_init( int num_snd, const Sample *sa, int freq, 
  62.           int channels, const char *sound_device );
  63.  
  64.  
  65. /* shutdown sample player, free mem, etc/etc..*/
  66. int 
  67. Snd_restore();
  68.  
  69.  
  70. /* play a sound effect in the given channel 1..n*/
  71. /* volume = integers from 0 (off) to 100 (full volume)*/
  72. int 
  73. Snd_effect( int nr, int channel );
  74.  
  75.  
  76. /* stop a channel (1..n) from playing*/
  77. /*void 
  78. Snd_reset(enum snd_channel channel);*/
  79.     
  80.  
  81. /* stop all channels from playing*/
  82. /*void 
  83. Snd_reset();*/
  84.     
  85.     
  86. #endif
  87.